package com.xthh._function._ini;

import android.content.Context;

import com.xthh._struct.HH_T_LoginInfo;
import com.xthh._struct.HH_T_SystemParams;

public class HH_INILoginInfo {
    public static void Save(Context ctx, HH_T_LoginInfo tl){
        if (tl != null){
            if (tl.getToken() != null)
                HH_INI.putString(new HH_T_SystemParams(null, ctx, null), "INKCUTE_LOGIN_TOKEN", tl.getToken());
            if (tl.getUserId() != null)
                HH_INI.putString(new HH_T_SystemParams(null, ctx, null), "INKCUTE_LOGIN_USERID", tl.getUserId());
            if (tl.getNickName() != null)
                HH_INI.putString(new HH_T_SystemParams(null, ctx, null), "INKCUTE_LOGIN_NICKNAME", tl.getNickName());
            if (tl.getUserCode() != null)
                HH_INI.putString(new HH_T_SystemParams(null, ctx, null), "INKCUTE_LOGIN_USERCODE", tl.getUserCode());
        }
    }

    public static HH_T_LoginInfo Get(Context ctx){
        return new HH_T_LoginInfo(HH_INI.getString(new HH_T_SystemParams(null, ctx, null), "INKCUTE_LOGIN_TOKEN"),
                HH_INI.getString(new HH_T_SystemParams(null, ctx, null), "INKCUTE_LOGIN_USERID"),
                HH_INI.getString(new HH_T_SystemParams(null, ctx, null), "INKCUTE_LOGIN_NICKNAME"),
                HH_INI.getString(new HH_T_SystemParams(null, ctx, null), "INKCUTE_LOGIN_USERCODE"),
                "",
                true);
    }
}
